package com.nursing.controller.Elder;

import com.nursing.bean.HealthRecord;
import com.nursing.model.Result;
import com.nursing.service.HealthRecordService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/healthRecord")
public class ElderHealthRecordController {
    private final HealthRecordService healthRecordService;

    public ElderHealthRecordController(HealthRecordService healthRecordService) {
        this.healthRecordService = healthRecordService;
    }


    @GetMapping("/getHealthRecordById")
    public Result<HealthRecord> getHealthRecordById(@RequestParam Integer id) {
        return Result.success(healthRecordService.getHealthRecordByElderId(id));
    }

    @PostMapping("/createOrUpdateHealthRecord")
    public Result<String> addHealthRecord(@RequestBody HealthRecord healthRecord) {
        healthRecordService.createOrUpdateHealthRecord(healthRecord);
        return Result.success("添加成功");
    }
}
